from django.contrib import admin

from popboard.models import (Post, ForumProfile, AbuseReport, Category, Thread, WatchList)

class AbuseReportAdmin(admin.ModelAdmin): 
    list_display = ("post", "submitter",)
    search_fields = ("post__body_raw","submitter__username",)

class ThreadAdmin(admin.ModelAdmin):
    list_display = ("title", "user", "created", "modified", "hits", "post_count", "category", "site",)
    search_fields = ("title","user__username",)
    list_filter = ("site",)
    date_hierarchy = 'created'

class CategoryAdmin(admin.ModelAdmin):
    list_display = ("name", "description","created","site",)
    search_fields = ("name", "description",)
    list_filter = ("site",)
    prepopulated_fields = {"slug": ('name',)}
    date_hierarchy = 'created'

class PostAdmin(admin.ModelAdmin):
    list_display = ("site", "created", "user", "thread", "ip", "body_raw", "censor",)
    search_fields = ("body_raw", "user__username",)
    list_filter = ("censor", "site",)
    date_hierarchy = 'created'

class ForumProfileAdmin(admin.ModelAdmin):
    list_display = ("user", "profile", "ppp", "tpp", "email_notifications",)
    search_fields = ("user__username", "profile",)
    list_filter = ("email_notifications",)

class WatchListAdmin(admin.ModelAdmin):
    list_display = ("user", "thread",)
    search_fields = ("user__username", "thread__title",)

admin.site.register(Post, PostAdmin)
admin.site.register(ForumProfile, ForumProfileAdmin)
admin.site.register(AbuseReport, AbuseReportAdmin)
admin.site.register(WatchList, WatchListAdmin)
admin.site.register(Category, CategoryAdmin)
admin.site.register(Thread, ThreadAdmin)